// import Vue from 'vue'
// import Vuex from 'vuex'
// //
// Vue.use(Vuex);

export const state = () => ({
  headers: true,
  footers: true,
  cartnumber: 0,
  logoUrl: "",
  titleCon: "",
  unreadNum: 0,
  service_num: 0,
  homeMenus: [
    { title: "首頁", url: "/" },
    { title: "商城", url: "/goods_cate" },
    { title: "售後政策", url: "/news_detail?id=1" },
    { title: "物流政策", url: "/news_detail?id=2" },
    { title: "隱私政策", url: "/news_detail?id=3" },
    { title: "關於我們", url: "/about_us" },
  ],
});

export const mutations = {
  isHeader(state, data) {
    state.headers = data;
  },
  isFooter(state, data) {
    state.footers = data;
  },
  cartNum(state, data) {
    state.cartnumber = data;
  },
  serviceNum(state, data) {
    state.service_num = data;
  },
  logo(state, data) {
    state.logoUrl = data;
  },
  homeMenus(state, data) {
    state.homeMenus = data;
  },
  titles(state, data) {
    state.titleCon = data;
  },
  unreadKefu(state, data) {
    state.unreadNum = data;
  },
};

export const actions = {
  nuxtServerInit({ commit }, { app }) {
    commit("unreadKefu", app.$cookies.get("unreadKefu"));
    commit("logo", app.$cookies.get("logo"));
    commit("titles", app.$cookies.get("titles"));
  },
};
